package com.android.webttest.dao;

import android.content.Intent;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;

import com.android.webttest.model.tableModel.GoodLike;

@Dao
public interface GoodLikeDao {
    @Insert
    void insert(GoodLike goodLike);

    @Query("DELETE FROM good_like")
    void deleteAllGoodLike();

    @Query("SELECT * FROM good_like WHERE good_id = :goodId LIMIT 1")
    GoodLike loadGoodLikeByGoodId(Integer goodId);


    /**
     * 封装方法：判断是否存在记录
     */
    default boolean existsGoodLikeByGoodId(Integer goodId) {
        return loadGoodLikeByGoodId(goodId) != null;
    }

    @Query("DELETE FROM good_like WHERE id = :id")
    void deleteGoodLikeById(Integer id);
}
